package com.heima.wemedia.scan.runner;

import com.heima.utils.common.SensitiveWordUtil;
import com.heima.wemedia.scan.dao.WmSensitiveDao;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 在spring项目启动完成之后会自动执行里面的 run
 */
@Component
public class WmNewsApplicationRunner implements ApplicationRunner {

    @Resource
    private WmSensitiveDao wmSensitiveDao;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //1. 查询敏感词列表
        List<String> wordsList = wmSensitiveDao.queryWordsList();
       
        //2.初始化DFA数据结构
        SensitiveWordUtil.initMap(wordsList);
    }
}